{% set pypi_name = 'osprofiler' %}
{% set upstream_version = upstream_version('3.4.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        OpenStack Profiler Library
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/osprofiler
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('PrettyTable') }}
BuildRequires:  {{ py3('WebOb') }}
BuildRequires:  {{ py3('ddt') }}
BuildRequires:  {{ py3('docutils') }}
BuildRequires:  {{ py3('elasticsearch') }}
BuildRequires:  {{ py3('importlib-metadata') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('oslo.concurrency') }}
BuildRequires:  {{ py3('oslo.config') }}
BuildRequires:  {{ py3('oslo.log') }}
BuildRequires:  {{ py3('oslo.utils') }}
BuildRequires:  {{ py3('pymongo') }}
BuildRequires:  {{ py3('python-subunit') }}
BuildRequires:  {{ py3('redis') }}
BuildRequires:  {{ py3('six') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('testtools') }}
BuildArch:      noarch

%description
OSProfiler provides a tiny but powerful library that is used by
most (soon to be all) OpenStack projects and their python clients. It
provides functionality to be able to generate 1 trace per request, that goes
through all involved services. This trace can then be extracted and used
to build a tree of calls which can be quite handy for a variety of
reasons (for example in isolating cross-project performance issues).

%package -n {{ py2name(py_versions='py3') }}
Summary:        OpenStack Profiler Library
Requires:       {{ py3('PrettyTable') }}
Requires:       {{ py3('WebOb') }}
Requires:       {{ py3('importlib-metadata') }}
Requires:       {{ py3('oslo.concurrency') }}
Requires:       {{ py3('oslo.config') }}
Requires:       {{ py3('oslo.log') }}
Requires:       {{ py3('oslo.utils') }}
Requires:       {{ py3('six') }}
%if 0%{?suse_version}
Obsoletes:      {{ py2name(py_versions='py2') }} < 3.0.0
%endif

%description -n {{ py2name(py_versions='py3') }}
OSProfiler provides a tiny but powerful library that is used by
most (soon to be all) OpenStack projects and their python clients. It
provides functionality to be able to generate 1 trace per request, that goes
through all involved services. This trace can then be extracted and used
to build a tree of calls which can be quite handy for a variety of
reasons (for example in isolating cross-project performance issues).

This package contains the Python 3.x module

%package -n python-osprofiler-doc
Summary:        Documentation for OSProfiler
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}

%description -n python-osprofiler-doc
Documentation for OSProfiler.

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
%{py3_build}

%install
%{py3_install}

# generate html docs
PBR_VERSION=%{version} %sphinx_build -b html doc/source doc/build/html
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%check
python3 -m stestr.cli run --black-regex '(^osprofiler.tests.unit.drivers.test_jaeger.JaegerTestCase.*$)'

%files -n {{ py2name(py_versions='py3') }}
%license LICENSE
%doc README.rst ChangeLog
%{python3_sitelib}/osprofiler
%{python3_sitelib}/*.egg-info
%{_bindir}/osprofiler

%files -n python-osprofiler-doc
%license LICENSE
%doc doc/build/html

%changelog
